<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>公司通告</title>
    <link rel="stylesheet" href="../../css/home.css" />
    <link rel="stylesheet" href="../../css/base.css" />
    <link rel="stylesheet" href="../../css/info-reg.css" />
    <link rel="stylesheet" href="../../css/info-mgt.css" />
	<link rel="stylesheet" href="../../css/WdatePicker.css" />
	<script type="text/javascript" src="../../js/jquery.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../js/WdatePicker.js"></script>
	<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
  </head>
	
  <body>
  <div class="title" style="width:99.7%;"><h2>搜索条件</h2></div>
	<div class="query" style="width:99.7%;">
		<div class="query-conditions ue-clear">
	        <div class="conditions name ue-clear">
	            <label>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题：</label>
	            <div class="select-wrap">
	                <div class="select-title ue-clear">
	                	<!-- 标题text文本框 -->
	                	<input type="text" id="title" style="width:100%; border:0px solid red;" placeholder="请输入标题内容" />
	                </div>
	            </div>
	        </div>
	        <div class="conditions time ue-clear">
	            <label>时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间：</label>
	            <div class="time-select">
	            	<input type="text" id="startTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="开始时间" />
	                <i class="icon"></i>
	            </div>
	            <span class="line">-</span>
	            <div class="time-select">
	            	<input type="text" id="endTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="结束时间" />
	                <i class="icon"></i>
	            </div>
	        </div>
	    </div>
	    <div class="query-btn ue-clear">
	    	<a href="javascript:;" class="confirm" id="search">查询</a>
	        <a href="javascript:;" class="clear" id="clean">清空条件</a> 
	    </div>
	</div>
	<!-- 通告------------------------------------------------------------ -->
    <div class="article half notice" style="width:100%;">
		<div class="wrap-l">
	        <div class="title ue-clear">
	            <h2>通知公告</h2>
	            <a href="javascript:;" class="more"></a>
	        </div>
	        <div class="content" style="height:30%;">
	        	<ul class="notice-list" id="ulPage">
	        		<!-- li分页 js动态添加 -->
	            </ul>
	        </div>
	    </div>
	</div>
	<br><br/><br><br/><br><br/><br><br/><br><br/><br>
	<!-- 分页按钮 ------------------------------------------------->
	<div style="margin:0px auto; width:100%; text-align:center;">
	  	<table id="tableLast" width="80%" align="center" border="0">
	  		<tr align="center">
	  			<td width="75%"></td>
	  			<td><a href="javascript:void(0);" id="headPage">首页</a></td>
	  			<td><a href="javascript:void(0);" id="backPage">上一页</a></td>
	  			<td align="right">当前页面:</td>
	  			<td width="8%" align="left"><input type="text" id="page" value="1" style="width:20%;">
	  				<a href="javascript:void(0);" id="skipPage">跳转</a>&nbsp;&nbsp;
	  				<label id="nowPage">1</label>/<label id="countPage"></label>
	  			</td>
	  			<td><a href="javascript:void(0);" id="nextPage">下一页</a></td>
	  			<td><a href="javascript:void(0);" id="lastPage">末页</a></td>
	  		</tr>
	  	</table>
	  	<br/>
  	</div>
	<!-- 通告详情显示 -->
	<div class="title" style="width:99.7%;" id="noticeDetail1"><h2>通告详情</h2></div>
	<div class="main" style="width:99.7%;" id="noticeDetail2">
		<p class="short-input ue-clear newstyle">
	    	<label>通告主题：</label>
	    	<font id="detailTitle"></font>
	    </p>
	    <p class="long-input ue-clear newstyle">
	    	<label>发布人：</label>
	    	<font id="detailPerson"></font>
	    </p>
	    <p class="short-input ue-clear newstyle">
	    	<label>发布时间：</label>
	    	<font id="detailTime"></font>
	    </p>   
	    <p class="short-input ue-clear newstyle">
	    	<label>发布内容：</label>
	    	<textarea id="detailText" disabled="disabled" rows="5" cols="80"></textarea>
	    </p>
	</div>
	
	<!-- 发布通知 -->
	<div class="title" id="noticeTopic1" style="display:none;"><h2>发布通知</h2></div>
	<div class="main" id="noticeTopic2" style="display:none;">
	<form id="addNoticeForm" action="publicInfoManager.action?method=addNotice" method="post">
	    <p class="long-input ue-clear">
	    	<label>通告标题：</label>
	        <input type="text" id="noticeTextTitle" name="title" placeholder="请输入标题" />
	    </p>
	    <p class="short-input ue-clear">
	    	<label>通告内容：</label>
	        <textarea id="noticeTextArea" name="content" placeholder="请输入内容"></textarea>
	    </p>
	 </form>
	</div>
	<div class="btn ue-clear" id="noticeTopic3" style="display:none;">
		<a href="javascript:;" class="confirm" id="confirm">确定</a>
	    <a href="javascript:;" class="clear" id="cleanContent">清空内容</a>
	    <a href="javascript:;" class="clear" id="return">返回</a>
	</div>
	
	
	<div class="query-btn ue-clear" id="noticeDetail3">
        <a href="javascript:;" class="clear" id="notice" >发布通知</a> 
    </div>
	
	
	
	<script type="text/javascript">
		//点击显示详情
		function showDetail(num){
			$("#detailTitle").text($("#annTitle"+num).text());
			$("#detailPerson").text($("#annAuthor"+num).text());
			$("#detailTime").text($("#annTime"+num).text());
			$("#detailText").val($("#annContent"+num).val());
		}
		
		var addterm=false;
		//发布通知 div切换 发布按钮
		function changeDiv(status1,status2){
			$("#noticeDetail1").css("display",status1);
			$("#noticeDetail2").css("display",status1);
			$("#noticeDetail3").css("display",status1);
			
			$("#noticeTopic1").css("display",status2);
			$("#noticeTopic2").css("display",status2);
			$("#noticeTopic3").css("display",status2);
		}
		$("#notice").click(function(){
			changeDiv("none","block");
		});
		//确认按钮 发布 刷新页面
		$("#confirm").click(function(){
			var title=$("#noticeTextArea").val();
			var content=$("#noticeTextTitle").val();
			if(title.length<=0||content.length<=0){
				alert("内容或标题为空");
				return;
			}
			$("#addNoticeForm").submit();
		});
		//删除 
		function deleteInfo(id){
			if(window.confirm("确认删除该条数据吗?")){
				window.location="publicInfoManager.action?method=deleteNotice&id="+id;
			}
		}
		
		
		//返回按钮
		$("#return").click(function(){
			changeDiv("block","none");
		});
		
		//定义分页方法
		var data="";
		$(function(){
			//条件查询
			$("#search").click(function(){
				addterm=true;//加条件查询控制变量
				data="nowPage=0&turnType=next";
				paging(data);
				$("#nowPage").text(1);
				$("#page").val(1);
			});
			//清空按钮
			$("#clean").click(function(){
				$("#title").val("");
				$("#startTime").val("");
				$("#endTime").val("");
			});
			$("#cleanContent").click(function(){
				$("#noticeTextArea").val("");
				$("#noticeTextTitle").val("");
			});
			
			//分页函数
			function paging(data){
				//判断是否要加条件查询
				if(addterm){
					//判断是否有查询条件
					if($("#title").val()!=""){
						data+="&ann_title="+$("#title").val();
					}
					if($("#startTime").val()!=""&&$("#endTime").val()!=""){
						data+="&ann_time="+$("#startTime").val()+","+$("#endTime").val();
					}else if($("#startTime").val()!=""&&$("#endTime").val()==""){
						data+="&ann_time="+$("#startTime").val()+",8888-08-08";
					}else if($("#startTime").val()==""&&$("#endTime").val()!=""){
						data+="&ann_time=1111-11-11,"+$("#endTime").val();
					}
				}
				//alert(data);
				//异步请求查询通告表
				$.ajax({
					type:"post",
					url:"accLwg*announce.paging",
					data:data,
					success:function(data){
					
						var str="";
						for(var i=0;i<data.data.length;i++){
							str+="<li class='ue-clear'>";
							str+="<a href='javascript:void(0);' onclick='showDetail("+i+");' id='annTitle"+i+"' class='notice-title'>"+data.data[i].annTitle+"</a>";
							//如果登录人部门id等于2 则加入删除按钮
							if("${login_User.userDeptId }"=="2"){
								str+="<div class='notice-time'><a href='javascript:void(0);' onclick='deleteInfo("+data.data[i].annId+")'>删除</a></div>";
							}
							str+="<div class='notice-time' id='annTime"+i+"'>"+data.data[i].annTime+"</div>";
							str+="<div class='notice-time' id='annAuthor"+i+"'>"+data.data[i].annAuthor+"</div>";
							str+="<input type='hidden' id='annContent"+i+"' value='"+data.data[i].annContent+"'></li>";
						}
						$("#ulPage").html(str);
						//向上取整总页数
						$("#countPage").text(Math.ceil(data.rowNum/10));
					}
				});
			}
			
			
			//刚进来 调用分页
			data="nowPage=0&turnType=next";
			paging(data);
			//首页
			$("#headPage").click(function(){
				if($("#nowPage").text()==1){
				}else{
					data="nowPage=0&turnType=next";
					paging(data);
					$("#nowPage").text(1);
					$("#page").val(1);
				}
			});
			//末页
			$("#lastPage").click(function(){
				if($("#nowPage").text()==$("#countPage").text()){
				}else{
					data="nowPage="+(parseInt($("#countPage").text())-1)+"&turnType=next";
					paging(data);
					$("#nowPage").text($("#countPage").text());
					$("#page").val($("#nowPage").text());
				}
			});
			//上一页
			$("#backPage").click(function(){
				if($("#nowPage").text()==1){
				}else{
					data="nowPage="+$("#nowPage").text()+"&turnType=back";
					paging(data);
					$("#nowPage").text(parseInt($("#nowPage").text())-1);
					$("#page").val($("#nowPage").text());
				}
			});
			//下一页
			$("#nextPage").click(function(){
				if($("#nowPage").text()==$("#countPage").text()){
				}else{
					data="nowPage="+$("#nowPage").text()+"&turnType=next";
					paging(data);
					$("#nowPage").text(parseInt($("#nowPage").text())+1);
					$("#page").val($("#nowPage").text());
				}
			});
			//跳转页面
			$("#skipPage").click(function(){
				if($("#page").val()>$("#countPage").text()||$("#page").val()<1||
				$("#page").val()==$("#nowPage").text()){
				}else{
					data="nowPage="+(parseInt($("#page").val())-1)+"&turnType=next";
					paging(data);
					$("#nowPage").text($("#page").val());
				}
			});
			
			//改变分页按钮字体大小
			$("#tableLast tr td").css("font-size","15px");
			$("#tableLast tr td").css("background","url(../../images/righttitlebig.png)");
			$("#btnNotice").css("background","url(../../images/righttitlebig.png)");
			
			//如果登录人部门id部位2 则隐藏发布通知按钮
			if("${login_User.userDeptId }"!="2"){
				$("#noticeDetail3").hide();
			}
			
			/*
			$(".select-title").on("click",function(){
				$(".select-list").hide();
				$(this).siblings($(".select-list")).show();
				return false;
			})
			$(".select-list").on("click","li",function(){
				var txt = $(this).text();
				$(this).parent($(".select-list")).siblings($(".select-title")).find("span").text(txt);
			})
			
			$("tbody").find("tr:odd").css("backgroundColor","#eff6fa");
			showRemind('input[type=text], textarea','placeholder');
			*/
		});
	</script>
  </body>
</html>
